home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id$
- *
- * AmiTCP/IP Dial Script Subroutine to put the modem to
- * command state.
- *
- * Copyright © 1995 AmiTCP/IP Group,
- * Network Solutions Development Inc.
- * All rights reserved.
- *
- *
- */
-
- /*
- * Set Inter-character delay to 100 ms.
- * Some modems need this.
- */
- options results
-
- Set InterCharDelay 100
- OldDelay = result /* save the old value */
-
- /*
- * Set the WaitFor timeout to 2 seconds.
- * Modem needs to respond in this time.
- */
- Set WaitForTimeout 2
- OldTimeOut = result /* save the old value */
-
- /* enable error signal */
- signal on error
- Status "Putting modem to the command state..."
-
- ModemOnline NO /* Do not use Carrier Detect if configured (yet) */
-
- /* Initialize variables */
- onCommandState = 0 /* Assume not in command state */
- retries = 0
- maxRetries = 10
-
- Flush /* Flush old input from serial */
-
- do until onCommandState
- /*
- * Test if the modem is in the command state
- */
- if (retries // 3 = 0) then do /* Output null command first */
- SendLn ""
- SendLn ""
- SendLn "AT"
- end
-
- WaitFor! "OK\r\n"
- res = result /* Save WaitFor's RC */
-
- if (res = 1) then do
- onCommandState = 1
- end
- else do
- if (retries > maxRetries) then do
- Status "Could not put modem to command state."
- exit 10
- end
- retries = retries + 1
- /*
- * Send three '+' chars to put the modem to the
- * command state
- */
- Set InterCharDelay 1000
- Pause 1
- Send '+++'
- Set InterCharDelay 100
- end
- end
-
- Status "Initializing modem"
-
- /*
- * &F - reset to factory defaults
- * &C1 - enable carrier detect
- * &D2 - disconnect if DTR drops
- * &K3
- * X3 - blind dial, recognize BUSY, report baud rate with CONNECT
- */
-
- Get ModemInitString
- SendLn ModemInitString
- WaitFor "OK"
-
- /*
- * return old values
- */
- Set WaitForTimeout OldTimeOut
- Set InterCharDelay OldDelay
- Status "Succeeded."
- exit 0
-
- error:
- Say "CommandState.adrx: Command on line" SIGL "returned" RC ":" SerScript.LASTERROR
- Exit 10
-